package mysgoog.pattern.StartGame;

import java.util.*;
import mysgoog.brown.*;
import mysgoog.brown.move.*;
import mysgoog.gtp.*;
/**
* @author Fu, Zhongyang
*/
public class BrownGenerator implements Generator
{

    private Color[] board = null;
    private int boardSize = 0;
    private int boardCount = 0;
    public StartGamePatternMatcher matcher = new StartGamePatternMatcher();

    public static void main(String[] arg)
    {
        BrownGenerator brown = new BrownGenerator();
        brown.set_board(13);
        brown.clearBoard();
        brown.genMove(Brown.BLACK);
    }

    public void clearBoard()
    {
        for (int i = 0; i < boardCount; i++)
            board[i] = Color.EMPTY;
    }

    @Override
    public void set_board(int size)
    {
        board = new Color[size * size];
        boardSize = size;
        boardCount = size * size;
    }

    @Override
    public void clear_board()
    {
        // TODO Auto-generated method stub

    }

    @Override
    public void play(int pos, int color)
    {
        // TODO Auto-generated method stub

    }

    @Override
    public void remove(int pos)
    {
        // TODO Auto-generated method stub

    }

    @Override
    public LinkedList<Move> genMove(int color)
    {
        LinkedList<Move> result = new LinkedList<Move>();
        copyBoard();
        Color c = null;
        switch (color)
        {
            case Brown.BLACK:
                c = Color.BLACK;
                break;
            case Brown.WHITE:
                c = Color.WHITE;
                break;
            case Brown.EMPTY:
                c = Color.EMPTY;
                break;
        }
        //int match = matcher.getMatch(board, c);
        int match = 0;
        if (match == -1)
            return result;
        Move move = new Move(match, Evaluator.PATTERN_MOVE, 100);
        result.add(move);
        return result;
    }

    public void copyBoard()
    {
        for (int i = 0; i < boardCount; i++)
        {
            switch (Brown.board[i])
            {
                case Brown.BLACK:
                    board[i] = Color.BLACK;
                    break;
                case Brown.WHITE:
                    board[i] = Color.WHITE;
                    break;
                case Brown.EMPTY:
                    board[i] = Color.EMPTY;
                    break;
            }
        }
    }

}
